\section{How Do I Output My Variables?}\label{how-do-i-output-my-variables}

Module developers are responsible for ``setting'' up the variables that will appear in the OutputFileStandard.

To do this is very simple.~ All you need to do is place a simple call to \emph{SetupOutputVariable} into your module for each variable to be available for reporting.~ This call should be done only once for each Variable/KeyedValue pair (see below).~ For HVAC and Plant components, this call is usually at the end of the ``GetInput'' subroutine. See the example module for an illustration of this. Other calls in the simulation routines will invoke the EnergyPlus \emph{OutputProcessor} automatically at the proper time to have the data appear in the OutputFileStandard.

For you the call is:

\begin{lstlisting}

SetupOutputVariable(VariableName, VariableUnit, ActualVariable, IndexTypeKey, VariableTypeKey,
  KeyedValue,ReportFreq, ResourceTypeKey,EndUseKey,GroupKey)


\end{lstlisting}


Interface statements allow for the same call to be used for either real or integer ``ActualVariable'' variables.~ A few examples from EnergyPlus and then we will define the arguments:

\begin{lstlisting}

SetupOutputVariable( "Site Outdoor Air Drybulb Temperature", OutputProcessor::Unit::C, OutDryBulbTemp,
  "Zone", "Average", "Environment" );

SetupOutputVariable( "Zone Mean Air Temperature", OutputProcessor::Unit::C, ZnAirRpt( Loop ).MeanAirTemp,
  "Zone", "Average", Zone( Loop ).Name );

SetupOutputVariable( "Fan Coil Heating Energy", OutputProcessor::Unit::J,
  FanCoil( FanCoilNum ).HeatEnergy, "System", "Sum", FanCoil( FanCoilNum ).Name );

SetupOutputVariable( "Zone Dehumidifier Electric Energy", OutputProcessor::Unit::J,
  ZoneDehumid( ZoneDehumidIndex ).ElecConsumption, "System", "Sum",
  ZoneDehumid( ZoneDehumidIndex ).Name,_, "Electric", "COOLING", _, "System" );

\end{lstlisting}


% table 4
\begin{longtable}[c]{p{1.5in}p{4.5in}}
\caption{SetupOutputVariable Arguments \label{table:setupoutputvariable-arguments}} \tabularnewline
\toprule
SetupOutput Variable Arguments & Description \tabularnewline
\midrule
\endfirsthead

\caption[]{SetupOutputVariable Arguments} \tabularnewline
\toprule
SetupOutput Variable Arguments & Description \tabularnewline
\midrule
\endhead

VariableName & String name of variable, no units should be included and no text should appear in brackets. \tabularnewline
VariableUnit & Actual units corresponding the the actual variable. An enum should be used from the list which is defined in OutputProcessor::Unit. \tabularnewline
ActualVariable & This should be the actual variable that will store the value.~ The OutputProcessor sets up a pointer to this variable, so it will need to be a SAVEd variable if in a local routine.~ As noted in examples, can be a simple variable or part of an array/derived type. \tabularnewline
IndexTypeKey & When this variable has its proper value.~ ‘Zone’ is used for variables that will have value on the global timestep (alias “HeatBalance”).~ ‘HVAC’ is used for variables that will have values calculated on the variable system timesteps (alias “System”, “Plant”) \tabularnewline
VariableTypeKey & Two kinds of variables are produced.~ ‘State’ or ‘Average’ are values that are instantaneous at the timestep (zone air temperature, outdoor weather conditions).~ ‘NonState’ or ‘Sum’ are values which need to be summed for a period (energy). \tabularnewline
KeyedValue & Every variable to be reported needs to have an associated keyed value. ~Zone Air Temperature is available for each Zone, thus the keyed value is the Zone Name. \tabularnewline
ReportFreq & This optional argument should only be used during debugging of your module but it is provided for the developers so that these variables would always show up in the OutputFile.~ (All other variables must be requested by the user). \tabularnewline
ResourceTypeKey & Meter Resource Type; an optional argument used for including the variable in a meter. The meter resource type can be 'Electricity', ‘Gas’, ‘Coal’, ‘FuelOil\#1’, ‘FuelOil\#2’, ‘Propane’, ‘Water’, or ‘EnergyTransfer’. \tabularnewline
EndUseKey & Meter End Use Key; an optional argument used when the variable is included in a meter. The end use keys can be: 'InteriorLights’, 'ExteriorLights', 'Heating', ‘Cooling’, 'DHW', 'Cogeneration', 'ExteriorEquipment', 'ZoneSource', 'PurchasedHotWater', 'PurchasedChilledWater', 'Fans', 'HeatingCoils', 'CoolingCoils', 'Pumps', 'Chillers', 'Boilers', 'Baseboard', 'HeatRejection', 'Humidifier', 'HeatRecovery' or ‘Refrigeration’. \tabularnewline
EndUseSubKey & Meter End Use Subcategory Key; an optional argument to further divide a particular End Use.~ This key is user-defined in the input object and can be any string, e.g., 'Task Lights', 'Exit Lights', 'Landscape Lights', 'Computers', or 'Fax Machines'. \tabularnewline
GroupKey & Meter Super Group Key; an optional argument used when the variable is included in a meter. The group key denotes whether the variable belongs to the building, system, or plant.The choices are: 'Building', 'HVAC' or 'Plant'. \tabularnewline
\bottomrule
\end{longtable}

As described in the \emph{Input Output Reference}, not all variables may be available in any particular simulation.~ Only those variables that will have values generated will be available for reporting.~ In the IDF, you can include a ``Output:VariableDictionary,regular;'' command that will produce the eplusout.rdd file containing all the variables with their IndexTypeKeys.~ This list can be used to tailor the requests for values in the OutputFileStandard.

This variable dictionary is separated into two pieces: regular reporting variables and meter variables.~ It can also be sorted by name (ascending).
